package com.single

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * Author atguigu
 * Date 2020/3/13 15:17
 */
object Repartition {
    def main(args: Array[String]): Unit = {
        val conf: SparkConf = new SparkConf().setAppName("Coalesce").setMaster("local[2]")
        val sc: SparkContext = new SparkContext(conf)
        val list1 = List(30, 50, 70, 60, 10, 20)
        val rdd1: RDD[Int] = sc.parallelize(list1, 5)

        println(rdd1.getNumPartitions) // 5
        val rdd2 = rdd1.repartition(2)
        println(rdd2.getNumPartitions) // 2

        sc.stop()


    }
}
